function ModifiedDatabaseFunction(e) {
	$(function() {
		$("#dialog-modified_confirm").dialog({
			resizable : true,
			height : 500,
			modal : true,
			buttons : {
				"確定" : function() {
					$(this).dialog("close");
					var id = $("#databaseId").val();
					id = jQuery.trim(id);

					var str = $("#stdkeyword").val();
					str = jQuery.trim(str);

					var str2 = $("#parent_id").val();
					str2 = jQuery.trim(str2);

					var str3 = $("#class").val();
					str3 = jQuery.trim(str3);

					$.ajax({
						type : "POST",
						url : "semanticNetworkMaitain.do",
						dataType : 'text',
						data : {
							str : str,
							str2 : str2,
							str3 : str3,
							id : id,
							button : "6"
						},

						error : function(xhr) {

						},
						success : function(Data) {
							if (Data = "success") {

								alert("修改成功");
								location.reload();
							}

						}
					});

				},
				"取消" : function() {
					$(this).dialog("close");

				}
			}
		});
	});

}
// ------------------------------------------------------------------------
function DeleteDatabaseFunction(e) {
	$(function() {
		$("#dialog-delete_confirm").dialog({
			resizable : true,
			height : 500,
			modal : true,
			buttons : {
				"確定" : function() {
					$(this).dialog("close");
					var id = $("#databaseId").val();
					id = jQuery.trim(id);

					$.ajax({
						type : "POST",
						url : "semanticNetworkMaitain.do",
						dataType : 'text',
						data : {

							id : id,
							button : "7"
						},

						error : function(xhr) {

						},
						success : function(Data) {
							if (Data = "success") {

								alert("刪除成功");
								location.reload();
							}

						}
					});

				},
				"取消" : function() {
					$(this).dialog("close");

				}
			}
		});
	});

}
// ------------------------------------------------------------------------
function AddDatabaseFunction(e) {
	$(function() {
		$("#dialog-add_confirm").dialog({
			resizable : true,
			height : 500,
			modal : true,
			buttons : {
				"確定" : function() {
					$(this).dialog("close");

					var str = $("#stdkeyword").val();
					str = jQuery.trim(str);

					var str2 = $("#parent_id").val();
					str2 = jQuery.trim(str2);

					var str3 = $("#class").val();
					str3 = jQuery.trim(str3);

					$.ajax({
						type : "POST",
						url : "semanticNetworkMaitain.do",
						dataType : 'text',
						data : {
							str : str,
							str2 : str2,
							str3 : str3,
							button : "8"
						},

						error : function(xhr) {

						},
						success : function(Data) {
							if (Data = "success") {

								alert("新增成功");
								location.reload();
							}

						}
					});

				},
				"取消" : function() {
					$(this).dialog("close");

				}
			}
		});
	});

}
// ------------------------------------------------------------------------

function ShowHideTable(e) {
	$.ajax({
		type : "POST",
		url : "semanticNetworkMaitainData.jsp",
		dataType : 'html',

		data : {
			type : $(this).attr("value")

		},

		error : function(xhr) {
			alert("Ajax request error!");

		},
		success : function(DataList) {

			$(e.data.str).html(DataList);
			$("input[type=radio]").click(countChecked);

		}
	});

	$(e.data.str).show();

}
// ------------------------------------------------------------------------
function countChecked(e) {

	var method = $("input[name='radio_1']:checked").val(); // radio 取值，注意寫法
	var split = method.split('#');
	$("#databaseId").val(split[0]);
	$("#stdkeyword").val(split[1]);
	$("#parent_id").val(split[2]);
	$("#class").val(split[3]);

}
// ------------------------------------------------------------------------
$(document).ready(function(e) {
	// $("input[type=radio]").click(countChecked);
	document.getElementById("dialog-modified_confirm").style.display = "none";// 隱藏
	document.getElementById("dialog-delete_confirm").style.display = "none";// 隱藏
	document.getElementById("dialog-add_confirm").style.display = "none";// 隱藏

	$("#a").attr('style', 'display:none');
	$("input[type=button]").button().click(function(event) {
		event.preventDefault();
	});

	$("#btn_1").on("click", {
		str : "#a"
	}, ShowHideTable);
	$("#btn_2").on("click", {
		str : "#a"
	}, ShowHideTable);
	$("#btn_3").on("click", {
		str : "#a"
	}, ShowHideTable);
	
	$("#modified").click(ModifiedDatabaseFunction);

	$("#delete").click(DeleteDatabaseFunction);
	$("#add").click(AddDatabaseFunction);
	$("#reset").click(function(event) {
		$("#stdkeyword").val('');
		$("#parent_id").val('');
		$("#class").val('');

	});

});